#include <iostream>
#include <string>
#include <unistd.h>
#include "Sock.hpp"

int main()
{
    Sock sock;
    sock.CreateClient(8080,"127.0.0.1");
    int sockfd=sock.Fd();
    while(true)
    {
        std::string messages;
        std::getline(std::cin,messages);
        if(messages=="quit") break;
        send(sockfd,messages.c_str(),messages.size(),0);
        char buffer[1024];
        bzero(buffer,sizeof(buffer));
        ssize_t s=recv(sockfd,buffer,sizeof(buffer)-1,0);
        if(s>0)
        {
            buffer[s]='\0';
            printf("server$ %s\n",buffer);
        }
    }
    close(sockfd);
    return 0;
}